﻿#pragma once

#include <memory>
#include <vulkan/vulkan.hpp>
#include "Containers/ThreadSafePtr.h"
#include "Containers/Map.h"
#include "Containers/Vector.h"
#include "Containers/String.h"

class CPreRenderShader;
class CWriteInShader;
class CVulkanShader;

class CVulkanShaders
{

public:
    CVulkanShaders();

    void UpdateShaders(const TVector<std::shared_ptr<CPreRenderShader>>& InShaders);

    std::shared_ptr<CVulkanShader> FindVulkanObj(TThreadSafeSharedPtr<CWriteInShader> Shader);

    //获取渲染线程内置Shader
    std::shared_ptr<CVulkanShader> GetVulkanOnlyShader(const CString& Name);
    //注册渲染线程内置Shader
    void RegisterVulkanOnlyShader(const CString& Name, std::shared_ptr<CVulkanShader> Shader);

    //从原始着色器代码创建着色器，并不负责注册
    static std::shared_ptr<CVulkanShader> CreateShaderFromRaw(
        const TVector<uint8_t> &InData
        , vk::ShaderStageFlagBits InStage);
protected:
    TMap< TThreadSafeSharedPtr<CWriteInShader>
        ,std::shared_ptr<CVulkanShader> > Shaders;

    //创建一些渲染线程独有的Shader，这些Shader不会暴露给其他线程
    void CreateVulkanOnlyShaders();

    TMap< CString 
        ,std::shared_ptr<CVulkanShader> > VulkanOnlyShaders;

};